import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class ImageCase extends StatelessWidget {
  const ImageCase({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 150,
      height: 150,
      decoration: BoxDecoration(
        color: Colors.amber,
        //圆角背景图
        borderRadius: BorderRadius.circular(150 / 2),
        //背景图写法能实现但有点麻烦
        // 可实现图片圆角
        // image: const DecorationImage(
        //   image: NetworkImage(
        //     'https://img.hongyoubizhi.com/picture/pages/regular/2021/05/31/13/33/77329543_p0_master1200.jpg?x-oss-process=image/resize,m_fill,w_1000',
        //   ),
        //   fit: BoxFit.cover,
        // ),
      ),
      child: Column(
        children: [
          //ClipOval 圆形裁切
          ClipOval(
            child: Image.network(
              'https://img.hongyoubizhi.com/picture/pages/regular/2021/05/31/13/33/77329543_p0_master1200.jpg?x-oss-process=image/resize,m_fill,w_1000',
              fit: BoxFit.cover,
              width: 50,
              height: 50,
            ),
          ),
          // ClipRRect 圆角拆切
          ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.network(
              'https://img.hongyoubizhi.com/picture/pages/regular/2021/05/31/13/33/77329543_p0_master1200.jpg?x-oss-process=image/resize,m_fill,w_1000',
              fit: BoxFit.cover,
              width: 50,
              height: 50,
            ),
          ),
          ClipRRect(
            borderRadius: BorderRadius.circular(10),
            // 使用本地图片资源：1.在pubspec.yaml中配置（注意空格） 2.在项目中创建assets文件夹，将图片放入其中
            child: Image.asset(
              'assets/open_eyes.png',
              fit: BoxFit.cover,
              width: 50,
              height: 50,
            ),
          )
        ],
      ),
      // child: Image.network( // network 只接收网络图片地址
      //   'https://img.hongyoubizhi.com/picture/pages/regular/2021/05/31/13/33/77329543_p0_master1200.jpg?x-oss-process=image/resize,m_fill,w_1000',
      //   fit: BoxFit.cover,
      // ),
    );
  }
}
